/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.nubotech.gwt.oss.client.util;

/**
 *
 * @author jonnakkerud
 */
public enum MimeType {
    application_oda("application/oda","oda"),    
    application_pdf("application/pdf","pdf"),
    application_postscript("application/postscript","eps,ai,ps"),    
    application_x_dvi("application/x-dvi","dvi"),
    application_zip("application/zip","zip"),
    application_x_tar("application/x-tar","tar"),
    text_html("text/html", "htm,html"),
    text_plain("text/plain", "text,c,cc,c++,h,pl,txt,java,el"),
    text_tab_separated_values("text/tab-separated-values", "tsv"),
    application_xml("application/xml", "xml");
       
    private final String type;
    private final String fileExtensions;
    MimeType(String type, String fileExtensions) {
        this.type = type;
        this.fileExtensions = fileExtensions;
    }
    
    private String type() {
        return this.type;
    }
    
    private String extensions() {
        return this.fileExtensions;
    }
    
    public static String lookup(String extension) {
        String result = null;
        for (MimeType m : MimeType.values()) {
            String ext = m.extensions();
            if (ext.indexOf(extension) > -1) {
                result = m.type();
                break;
            }
        }
        
        return result;
    }
    
    
}
